"use strict";

var serverIP = "http://localhost:91/api/";
var serverIP = "http://183.195.106.118:8150/fec-api/api/";// dev
//var serverIP = "https://cnmpse2e-itg.ext.hp.com/fec-api/api/";//itg
//var serverIP = "https://mpse2e.ext.hp.com/fec-api/api/";//pro
//var serverIP = "https://mpse2e.ext.hp.com.cn/fec-api/api/";//pro
var serverIP = "https://chinabp-itg.ext.hp.com.cn/fec-api/api/";//

// var serverIP = "http://117.185.95.186:88/api/";

var tagArr=["f-card","f-card-label","f-card-text","f-card-title","f-a","f-button","f-dropdown","f-input","f-line",
    "f-status-circle","f-back","f-section-title","f-section-icon","f-buttongroup", "f-status-button","f-card-title2",
    "f-option","f-img","f-card-text2","f-image-group","f-signer","f-signer-text","f-signer-user","f-textarea","f-upload",
    "f-uploadto","f-hint","f-th","f-tr","f-td","f-br","f-time","f-checkbox","f-sign","f-operation","f-title","f-row","f-icon","f-search"];
function saveToken(token) {
    sessionStorage.setItem("saveCheck", token);
    localStorage.setItem("saveCheck", token);
}

function getToken() {
	return sessionStorage.getItem("saveCheck");
}

function saveUser(user) {
    sessionStorage.setItem("user", JSON.stringify(user));
}

function getUser() {
    try {
        return !sessionStorage.getItem("user") ? {} : JSON.parse(sessionStorage.getItem("user"))
    } catch (e) {
        return {}
    }
}

//移动端获得用户信息
function checkPhone(type){
    var head = document.getElementsByTagName('head')[0];	
    var sUserAgent = navigator.userAgent.toLowerCase();
    if( sUserAgent.indexOf(type) > -1){
        return true;
    }
    return false;
}
/**
 * 校验只要是数字（包含正负整数，0以及正负浮点数）就返回true
 **/

function isNumber(val){

    var regPos = /^\d+(\.\d+)?$/; //非负浮点数
    var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
    if(regPos.test(val) || regNeg.test(val)){
        return true;
    }else{
        return false;
    }

}

function reloadJs(){
    var script = document.createElement("script");
     script.src = "js/frui.js";
//    script.src = "https://166036.com/frui.js";
    document.body.appendChild(script);
}

function testOl(cacheUser){
	if(document.getElementById('usernameId')){
		document.getElementById('usernameId').value = cacheUser.username;
		document.getElementById('passwordId').value = cacheUser.password;
		localStorage.setItem("username", cacheUser.username);
		localStorage.setItem("password", cacheUser.password);
		
		var appElement = document.querySelector('[ng-controller=loginController]');
		var $scope = angular.element(appElement).scope(); 
		$scope.fillUser();
	}
}

function mjBlhResult(msg){
}
  //如果token为空，则跳转到登陆页面
    if(!getToken()){
        setTimeout(function () {
            alert("未登录");
        }, 400);

    }


